package com.itheima.sort;

public class BinarySearch {
    public static int binarySearch(int[] arr,int target){
        int low = 0;
        int high = arr.length-1;
        while(low<=high){
            int mid =(low+high)>>>1;
            if(target==arr[mid]){
                return mid;
                }else if(target<arr[mid]){
                high =mid-1;
                }else{
                low = mid+1;
            }
        }
        return  -1;
    }
}
